const http = require("http");
const fs = require("fs");
const mysql = require("mysql");

var con = mysql.createConnection({
        host: "192.168.31.144",
        port: 3306,
        user: "root",
        password: "ddd",
        database: "blogDataBase"
})

var selectSql = "select createTime from blog where blogId=?";
var blogId = process.argv[2];

con.query(selectSql, [blogId], (err,result) => {
        if(err){
                console.log(err);
        }
        else{
                var blogList = result;
                for(var i = 0; i < blogList.length; i++){
                        console.log(blogList[i]['createTime']);
                }
        }
})

http.createServer((req,res) => {
        var fileContent = fs.readFileSync("./chapterList.html");
        res.writeHead(200, {"Content-Type": "text/html;charset=utf8"});
        res.write(fileContent);
        res.end();

        if(req.url == '/getChapterList'){
                req.on("data", (chunk) => {
                        var str = "";
                        str += chunk;
                })
        
                req.on("end", () => {
                    
                })
        }


}).listen(8084)



